﻿using Microsoft.Practices.Unity;
using System;
using System.Data.SqlServerCe;

namespace WindowsFormsApplication2
{
    //public class ContactsRepository:IRepository<Contact>
    //{

    //    public System.Collections.Generic.List<Contact> Read(string commandText)
    //    {
    //        return new System.Collections.Generic.List<Contact> 
    //        {
    //            new Contact{Id=1,FirstName="a",LastName="b"}
    //        };
    //    }
    //}
    public class ContactsRepository : Repository<Contact>
    {
        public ContactsRepository(IDbSettings settings)
            : base(settings)
        {

        }

        public override Contact Map(SqlCeDataReader reader)
        {
            Contact contact = new Contact();
            contact.Id = Convert.ToInt32(reader["Id"]);
            contact.FirstName = reader["FirstName"] as string;
            contact.LastName = reader["LastName"] as string;
            //contact.FullName = contact.FirstName + " " + contact.LastName;
            return contact;
        }
    }
}
